package org.example.controller;

import org.example.entity.Book;

import org.example.param.BookParam;
import org.example.service.BookService;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/book")
public class BookController {

    @Resource
    private BookService bookService;  // 使用依赖注入注入BookService


    // 面向用户的信息查询
    @GetMapping("/check")
    public Object check(BookParam param) {
        return bookService.check(param);  // 调用BookService的check方法
    }

    // 保存书籍信息
    @PostMapping("/save")
    public Map<String, Object> save(Book book) {
        return bookService.save(book);  // 调用BookService的save方法
    }

    @PostMapping("/change")
    public Map<String, Object> change(Book book) {
        return bookService.change(book);
    }
    @PostMapping("/batch-import")
    public Map<String, Object> batchImport(@RequestParam("file") MultipartFile file) {
        return bookService.importExcel(file);
    }

}
